package com.lhc.nacosprovider.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @author liuchaoqun
 * @date 2022/7/5
 * @Description Aop打印日志
 */
@Component
@Aspect
public class LogAspect {

    @Pointcut("@annotation(com.lhc.nacosprovider.annotation.needAuth)")
    public void point() {

    }

//    @Before("point()")
//    public void beforeAop() {
//        System.out.println("前置通知");
//    }
//
//    @After("point()")
//    public void afterAop() {
//
//        System.out.println("后置通知");
//    }

    @Around("point()")
    public String aroundAop(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("环绕通知前");
        Object response = proceedingJoinPoint.proceed();
        System.out.println("环绕通知后");
        return (String) response;
    }
}
